<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" xmlns:a4j="http://richfaces.org/a4j">

<h:head>
	<title>Create Packet</title>
</h:head>
<h:body>
		<h3>Creazione del pacchetto e aggiunta dell'hotel</h3>
		<h:form id="bb">
			<p:panel header="filter form">
				<h:panelGrid columns="3" id="regGrid1">
					<h:outputLabel for="city">inser the city for your packet:</h:outputLabel>
						<p:inputText id="city" value="#{PacketBean.city}" />
						<p:message for="city" />
				</h:panelGrid>
				<p:commandButton value="Search!" update="bb,:cc,:dd" id="ajax"  actionListener="#{PacketBean.search()}"/>
             <h6>NB: after submit Search, press F5 in order to refresh the page</h6>
					<h:dataTable value="#{PacketBean.hotels}" var="item">
    					<h:column>#{item}</h:column>
					</h:dataTable>
			</p:panel>
		</h:form>

	<h:form >
		<p:panel header="Creazione" id="form">
			<h:panelGrid columns="3" id="regGrid">
	

			<h:outputLabel for="hotel">hotel ID:</h:outputLabel>
			<p:inputText id="hotel" value="#{PacketBean.packetDTO.hotel}" />
			<p:message for="hotel" />

			<h:outputLabel for="description">description:</h:outputLabel>
			<p:inputText id="description"
				value="#{PacketBean.packetDTO.description}" />
			<p:message for="description" />

			<h:outputLabel for="start">start:</h:outputLabel>
			<p:inputMask id="start" value="#{PacketBean.packetDTO.start}"
				mask="99/99/9999">
				<f:convertDateTime pattern="dd/MM/yyyy" />
			</p:inputMask>
			<p:message for="start" />

			<h:outputLabel for="end">end:</h:outputLabel>
			<p:inputMask id="end" value="#{PacketBean.packetDTO.end}"
				mask="99/99/9999">
				<f:convertDateTime pattern="dd/MM/yyyy" />
			</p:inputMask>
			<p:message for="end" />

			<h:outputLabel for="price">price:</h:outputLabel>
			<p:inputText id="price" value="#{PacketBean.packetDTO.price}" />
			<p:message for="price" />

			<h:outputLabel for="spots">open spots:</h:outputLabel>
			<p:inputText id="spots" value="#{PacketBean.packetDTO.spots}" />
			<p:message for="spots" />


			<h:outputLabel for="visibility">Visibility:</h:outputLabel>
			<p:inputText id="visibility"
				value="#{PacketBean.packetDTO.visibility}">
				<f:validator validatorId="validateBoolean" />
			</p:inputText>
			<p:message for="visibility" />
			
			

			</h:panelGrid>
			<p:commandButton value="CREATE" update="regGrid" actionListener="#{PacketBean.register()}"/>
			</p:panel>
	</h:form>
	
	
	<h3>Flight add</h3>
	<h:form id="cc">
	<h5>search for arrival airports</h5>
	<h:dataTable value="#{PacketBean.arrivalFlights}" var="item">
    					<h:column>#{item}</h:column>
					</h:dataTable>
					
	<h5>search for departure airport</h5>
	<h:dataTable value="#{PacketBean.departureFlights}" var="item">
    					<h:column>#{item}</h:column>
					</h:dataTable>
	
	
		<p:panel header="insert the id of flights">
			<h:panelGrid columns="3" id="regGrid">
	

			<h:outputLabel for="Id">departure flight:</h:outputLabel>
			<p:inputText id="Id" value="#{PacketBean.voloAndata}" />
			<p:message for="Id" />

			<h:outputLabel for="Id1">return flight:</h:outputLabel>
			<p:inputText id="Id1"
				value="#{PacketBean.voloRitorno}" />
			<p:message for="Id1" />
	<p:commandButton value="CREATE" update="regGrid" actionListener="#{PacketBean.registerFlight()}"/>

			</h:panelGrid>
			</p:panel>
	</h:form>
	<h:form id="dd">
	<h5> Search for attractions </h5>	
	<h:dataTable value="#{PacketBean.attractions}" var="item">
    					<h:column>#{item}</h:column>
					</h:dataTable>
	</h:form>				
	<h5>Insert the id of the attractions listed above</h5>
	<h:form id="aa">
		<p:panel header="insert">
			<h:panelGrid columns="3" id="regGrid">
	

			<h:outputLabel for="Id2">attraction #</h:outputLabel>
			<p:inputText id="Id2" value="#{PacketBean.temp}" />
			<p:message for="Id2" />
			<p:commandButton value="Add" update="aa" id="ajax"  actionListener="#{PacketBean.addAttraction}"/>
			
			</h:panelGrid>
			</p:panel>
			<h:dataTable value="#{PacketBean.attractionsId}" var="item">
    					<h:column>#{item}</h:column>
					</h:dataTable>
	</h:form>
	
			<p:commandButton value="Save" update="aa" id="ajax"  actionListener="#{PacketBean.registerAttraction}"/>
			
	
	
	<h:link outcome="/admin/index" value="HomePage" />
	<br />
</h:body>

</html>